/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { message } from 'antd';
import request from '../utils/request';

// 开通或关闭即时配送功能
export async function deliveryStatus(params) {
  return request('/Api/Handle/run', {
    method: 'POST',
    body: {
      data: JSON.stringify({
        data: params,
        run: '/Valuation/add',
        time: new Date().getTime(),
      }),
    },
  });
}

// 获取定制公众号列表
export async function getWxList(params) {
  return request('/Api/Handle/run', {
    method: 'POST',
    body: {
      data: JSON.stringify({
        data: params,
        run: '/Delivery/getWxList',
        time: new Date().getTime(),
      }),
    },
  });
}

// 轮询检查扫描结果
export async function checkScan(params) {
  return request('/Api/Handle/run', {
    method: 'POST',
    body: {
      data: JSON.stringify({
        data: params,
        run: '/Delivery/loopCheckQrImg',
        time: new Date().getTime(),
      }),
    },
  });
}

// 获取二维码
export async function getAuthQrcode(params) {
  return request('/Api/Handle/run', {
    method: 'POST',
    body: {
      data: JSON.stringify({
        data: params,
        run: '/Delivery/auth',
        time: new Date().getTime(),
      }),
    },
  });
}

// 获取快递员
export async function getWxCourierList(params) {
  return request('/Api/Handle/run', {
    method: 'POST',
    body: {
      data: JSON.stringify({
        data: params,
        run: '/Delivery/getWxCourierList',
        time: new Date().getTime(),
      }),
    },
  });
}

// 导入定制公众号快递员
export async function importCourier(params) {
  return request('/Api/Courier/importCourierInfo', {
    method: 'POST',
    body: params,
  });
}

// 设置限额
export async function allowanceCount(params) {
  return request('/Api/Handle/run', {
    method: 'POST',
    body: {
      data: JSON.stringify({
        data: params,
        run: '/Courier/setItemToCache',
        time: new Date().getTime(),
      }),
    },
  });
}

// 修改限额
export async function modifyCount(params) {
  return request('/Api/Handle/run', {
    method: 'POST',
    body: {
      data: JSON.stringify({
        data: params,
        run: '/Courier/changeNumber',
        time: new Date().getTime(),
      }),
    },
  });
}

// 开通或关闭快宝快拣功能
export async function quickStatus(params) {
  return request('/Api/Handle/run', {
    method: 'POST',
    body: {
      data: JSON.stringify({
        data: params,
        run: '/Valuation/multiAdd',
        time: new Date().getTime(),
      }),
    },
  });
}

// 巴枪
export async function configuraTion(params) {
  return request('/Api/Handle/run', {
    method: 'POST',
    body: {
      data: JSON.stringify({
        data: params,
        run: '/Valuation/gun',
        time: new Date().getTime(),
      }),
    },
  });
}

// 巴枪下拉
export async function configuraSelect(params) {
  return request('/Api/Handle/run', {
    method: 'POST',
    body: {
      data: JSON.stringify({
        data: params,
        run: '/Valuation/select',
        time: new Date().getTime(),
      }),
    },
  });
}

// 批量删除
export async function batchDelete(params) {
  return request('/Api/Courier/delCourier', {
    method: 'POST',
    body: {
      data: JSON.stringify(params),
    },
  });
}

// 重新申请
export async function reapply(params) {
  return request('/Api/Courier/reapplyCourier', {
    method: 'POST',
    body: params,
  });
}

// 移动业务员
export async function transferOperator(params) {
  return request('/Api/Courier/transferCourier', {
    method: 'POST',
    body: {
      data: JSON.stringify(params),
    },
  });
}
/**
 * 业务员开启关闭共配权限
 *  */
export function triggerOpenGp(params) {
  return new Promise(resolve => {
    request('/Api/Courier/editStatus', {
      method: 'POST',
      body: params,
    }).then(res => {
      const { code, msg } = res;
      if (code == 0) {
        resolve();
      } else {
        message.error(msg);
      }
    });
  });
}
